package com.peking.donations.plugins.pay.wx.utils;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * User: rizenguo Date: 2014/10/29 Time: 14:40 这里放置各种配置数据
 */
@Component
@ConfigurationProperties(prefix = "wx.pay")
public class Configure {

    // 这个就是自己要保管好的私有Key了（切记只能放在自己的后台代码里，不能放在任何可能被看到源代码的客户端程序中）
    // 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名，生成的签名会放在Sign这个字段，API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证
    // 收到API的返回的时候也要用这个key来对返回的数据算下签名，跟API的Sign数据进行比较，如果值不一致，有可能数据被第三方给篡改


    private String key;

    private String secret;
    // 微信分配的公众号ID（开通公众号之后可以获取到）
    private String appID;

    // 微信支付分配的商户号ID（开通公众号的微信支付功能之后可以获取到）
    private String mchID;

    // 受理模式下给子商户分配的子商户号
    private String subMchID;

    // HTTPS证书的本地路径
    private String certLocalPath;

    // HTTPS证书密码，默认密码等于商户号MCHID
    private String certPassword;

    private String notifyUrl;

    private String notifyIp;


    public String getAppID() {
        return appID;
    }

    public void setAppID(String appID) {
        this.appID = appID;
    }

    public String getCertLocalPath() {
        return certLocalPath;
    }

    public void setCertLocalPath(String certLocalPath) {
        this.certLocalPath = certLocalPath;
    }

    public String getCertPassword() {
        return certPassword;
    }

    public void setCertPassword(String certPassword) {
        this.certPassword = certPassword;
    }


    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getMchID() {
        return mchID;
    }

    public void setMchID(String mchID) {
        this.mchID = mchID;
    }

    public String getSubMchID() {
        return subMchID;
    }

    public void setSubMchID(String subMchID) {
        this.subMchID = subMchID;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
    }

    public String getNotifyIp() {
        return notifyIp;
    }

    public void setNotifyIp(String notifyIp) {
        this.notifyIp = notifyIp;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (!(o instanceof Configure))
            return false;

        Configure configure = (Configure) o;

        if (key != null ? !key.equals(configure.key) : configure.key != null)
            return false;
        if (appID != null ? !appID.equals(configure.appID) : configure.appID != null)
            return false;
        if (mchID != null ? !mchID.equals(configure.mchID) : configure.mchID != null)
            return false;
        return subMchID != null ? subMchID.equals(configure.subMchID) : configure.subMchID == null;

    }

    @Override
    public int hashCode() {
        int result = key != null ? key.hashCode() : 0;
        result = 31 * result + (appID != null ? appID.hashCode() : 0);
        result = 31 * result + (mchID != null ? mchID.hashCode() : 0);
        result = 31 * result + (subMchID != null ? subMchID.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Configure{" + "appID='" + appID + '\'' + ", key='" + key + '\'' + ", mchID='" + mchID + '\''
                + ", subMchID='" + subMchID + '\'' + ", certLocalPath='" + certLocalPath + '\'' + ", certPassword='"
                + certPassword + '\'' + '}';
    }
}
